<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
cfc('core')->checklogin();
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
$return=array();
if($_RQ['op']=='get'){
	$member=model('core/member')->detail($_SESSION['uid'],array('credit1','credit2','credit3','credit4','credit5','credit6','mobile','avatar','username','nickname'));
	$item=pdo_get('jy_allinpay_paylog',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['logid']));
	$item['nickname']=$$member['nickname']?:$member['username'];
	$tips='支付确认短信验证码有效时间为2分钟！';
	$return['item']=$item;
	$return['tips']=$tips;
	set_html('title','支付确认');
	exi($return);
}
if($_RQ['op']=='getsmspost'){
	$postdata=get_postdata();
	if(!$postdata['reqsn']){
		exi('订单异常！','error');
	}
	$postdata['tid']=$postdata['reqsn'];
	$res=$this->model('model')->payapplyagree($postdata,1);
	exi('获取成功！');
}
if($_RQ['op']=='checkpost'){
	$postdata=get_postdata();
	if(!$postdata['smscode']){
		exi('请输入验证码！','error');
	}
	$response_data=json_decode($postdata['response_data'],true);
	$postdata['thpinfo']=$response_data['thpinfo'];
	$res=$this->model('model')->payagreeconfirm($postdata);
	pdo_update('jy_allinpay_paylog',array('ispay'=>1,'response_data'=>ijson_encode($res)),array('uniacid'=>$_SESSION['uniacid'],'id'=>$postdata['id']));
	$item=pdo_get('jy_allinpay_paylog',array('uniacid'=>$_SESSION['uniacid'],'id'=>$postdata['id']));
	$returl=$item['returl'];
	$pay_log=pdo_get('core_paylog',array('uniacid' =>$_SESSION['uniacid'],'tid'=>$item['reqsn']));
	$difee=$pay_log['di_fee'];
	$di_open=$pay_log['di_fee']>0?1:0;
	cfc('pay')->upcredit_notify($pay_log,$di_open,$difee,'union_online');
	exi('支付成功！','',$returl?:'jy_weishop/order.list/');
}